package com.cysion.study.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.cysion.study.ktbox.base.BaseAdapter
import com.cysion.study.ktbox.base.BaseViewHolder
import com.cysion.study.ktbox.image.RoundTransform
import com.cysion.study.R
import com.cysion.study.entity.CommentsEntity
import kotlinx.android.synthetic.main.item_comments.view.*

class CommentsAdapter(mEntities: MutableList<CommentsEntity>, mContext: Context) :
    BaseAdapter<CommentsEntity>(mEntities, mContext) {

    companion object {

        //点击事件
        const val refuse = 2000
        const val agree = 2001
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<CommentsEntity> {
        return ProMoneyHolder(
            LayoutInflater.from(mContext).inflate(R.layout.item_comments, parent, false)
        )
    }

    class ProMoneyHolder(itemView: View) : BaseViewHolder<CommentsEntity>(itemView) {
        override fun fillData(obj: CommentsEntity, position: Int) {
            itemView?.apply {
                //                itemView.tv_data.text=
                 Glide.with(context).load(obj.fromUserHeadImageUrl)
                  .apply(RequestOptions.placeholderOf(R.mipmap.place_holder_big))
                  .apply(RequestOptions.bitmapTransform(RoundTransform(6))).into(iv_head)
                tv_title.text = obj.fromUserName
                tv_data.text = obj.createTime
                tv_content.text = obj.content

            }
        }

    }
}